<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path;
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<title>工作审批-云校通</title>
<jsp:include page="/WEB-INF/page/common/_header.jsp"></jsp:include>
</head>
<body ontouchstart style="background: #fff;">
	<div class="weui_tab tab-bottom">
		<div class="weui_tab_bd">
			<div class="sp_tab">
              <ul>
                <li class="l_bull tab3"><a>我要审批</a></li>
                <li class="r_gry tab4"><a>我的申请</a></li>
              </ul>
            </div>
            
            <div class="weui_tab kcfd-list1" id="tab3">
	            <div class="weui_navbar">
	                <div class="weui_navbar_item" id="dwspList">
	                    	待我审批
	                </div>
	                <div class="weui_navbar_item" id="wyspList">
	                    	我已审批
	                </div>
	                
	            </div>
	            <div class="weui_tab_bd">
	                
		            <div class="weui_panel weui_tab_bd_item qingjia mt0">
			            <div class="weui_panel_bd" id="dwspListTable">
			              
			            </div>
			            <div class="dropload-down">
						    <div class="loadData dropload-hasData">点击加载更多数据...</div>
						</div>
		            </div>
			        
		            <div class="weui_panel weui_tab_bd_item qingjia mt0">
			            <div class="weui_panel_bd" id="wyspListTable">
			                
			            </div>
			            <div class="dropload-down">
						    <div class="loadData dropload-hasData">点击加载更多数据...</div>
						</div>
		            </div>
	            </div>
	        </div>
	        
	        <div class="weui_tab kcfd-list1 hide" id="tab4">
	            <div class="weui_navbar">
	                <div class="weui_navbar_item" id="myList">
	                    	我申请的
	                </div>
	                <div class="weui_navbar_item" id="ccList">
	                    	抄送我的
	                </div>
	                
	            </div>
	            <div class="weui_tab_bd">
	                
		            <div class="weui_panel weui_tab_bd_item qingjia mt0">
			            <div class="weui_panel_bd" id="myListTable">
			                
			            </div>
			            <div class="dropload-down">
						    <div class="loadData dropload-hasData">点击加载更多数据...</div>
						</div>
		            </div>
			        
		            <div class="weui_panel weui_tab_bd_item qingjia mt0">
			            <div class="weui_panel_bd" id="ccListTable">
			               
			            </div>
			            <div class="dropload-down">
						    <div class="loadData dropload-hasData">点击加载更多数据...</div>
						</div>
		            </div>
	            </div>
	            
	            <div class="addBtnnew" id="addBtnnew">
					<div class="linea"></div>
					<div class="lineb"></div>
		        </div>
	        </div>
		</div>
	</div>
	
	<!--弹窗-->				
	<div class="weui_mask ueureiu weui_mask_visible" style="display: none;z-index:600">
	</div>
	<!--End弹窗-->
	
	<!-- 新增审批 start-->
	<div id="add_div_box" class="weui_tab tab-bottom" style="display:none;z-index: 600;background-color: #f8f8f8;">
		<div class="weui_tab_bd">
	        <div class="weui-header bg-blue"> 
	        	<div class="weui-header-left" id="addBack"> <a class="icon icon-109 f-white">取消</a>  </div>
				<h1 class="weui-header-title"></h1>
			</div>
			<div class="weui_grids index_grids type3">
                <a href="<%=basePath %>/ls/work/approval/overtimeApply/add" class="weui_grid js_grid">
                    <div class="weui_grid_icon">
                        <img src="<%=basePath%>/images/jiabanshenqing@3x.png" alt="加班申请">
                    </div>
                    <p class="weui_grid_label">
                       	 加班申请
                    </p>
                </a>
                <a href="<%=basePath %>/ls/work/approval/schoolBus/add" class="weui_grid js_grid">
                    <div class="weui_grid_icon">
                        <img src="<%=basePath%>/images/xiaocheshenqing@3x.png" alt="校车申请">
                    </div>
                    <p class="weui_grid_label">
                       	 校车申请
                    </p>
                </a>
                <a href="<%=basePath %>/ls/work/approval/teachingGoods/add" class="weui_grid js_grid">
                    <div class="weui_grid_icon">
                        <img src="<%=basePath%>/images/dianjiaowupin@3x.png" alt="电教物品">
                    </div>
                    <p class="weui_grid_label">
                       	 教学用品
                    </p>
                </a>
                <a href="<%=basePath %>/ls/work/approval/copyPaper/add" class="weui_grid js_grid">
                    <div class="weui_grid_icon">
                        <img src="<%=basePath%>/images/fuyinyouyin@3x.png" alt="复印油印">
                    </div>
                    <p class="weui_grid_label">
                        	复印油印
                    </p>
                </a>
                <a href="<%=basePath %>/ls/work/approval/printingPaper/add" class="weui_grid js_grid">
                    <div class="weui_grid_icon">
                        <img src="<%=basePath%>/images/dayinzhi@3x.png" alt="打印纸">
                    </div>
                    <p class="weui_grid_label">
                      	  打印纸
                    </p>
                </a>
                
            </div>
         </div>
    </div>	
	<jsp:include page="/WEB-INF/page/common/_footer.jsp"></jsp:include>
	<script>
		var isLoadwyspList = false,isLoadmyList = false,isLoadccList = false;
		var dwspPage = 1, dwspRows = 5, wyspPage = 1, wyspRows = 5, 
			myPage = 1,myRows = 5,ccPage = 1, ccRows = 5;
		$(function() {
			$(".tab3").click(function() {
				$(this).removeClass("l_gry").addClass("l_bull").siblings().removeClass("r_bull").addClass("r_gry");
				$('#tab3').show();
				$('#tab4').hide();
			});
			$(".tab4").click(function() {
				$(this).removeClass("r_gry").addClass("r_bull").siblings().removeClass("l_bull").addClass("l_gry");
				$('#tab4').show();
				$('#tab3').hide();
				if(!isLoadmyList){
					isLoadmyList = true;
					var param = {
						page: myPage,
						rows: myRows,
						applyerId: "${user.teacher.id}"
					}
					myPage += 1;
					loadItem(param, "myListTable");
				}
			});
			$('#tab3').tab({
				defaultIndex: 0,
				activeClass: "tab-blue "
			});
			$('#tab4').tab({
				defaultIndex: 0,
				activeClass: "tab-blue "
			});
			//取消新增
			$("#addBack").click(function() {
				$('.ueureiu').hide();
				$("#add_div_box").hide();
			});
			$("#addBtnnew").click(function() {
				$('.ueureiu').show();
				$("#add_div_box").show();
			});
			$("#wyspList").click(function() {
				if(!isLoadccList){
					isLoadwyspList = true;
					var param = {
						page: wyspPage,
						rows: wyspRows,
						approvalStatus: "000",
						approverId: "${user.teacher.id}"
					}
					wyspPage += 1;
					loadItem(param, "wyspListTable");
				}
			})
			$("#ccList").click(function() {
				if(!isLoadccList){
					isLoadccList = true;
					var param = {
						page: ccPage,
						rows: ccRows,
						ccId: "${user.teacher.id}"
					}
					ccPage += 1;
					loadItem(param, "ccListTable");
				}
			})
			$(".dropload-down").on("click", ".dropload-hasData", function() {
				var id = $(this).closest(".weui_tab_bd_item").find(".weui_panel_bd").attr("id");
				var param = {};
				if(id == 'dwspListTable') {
					param.page = dwspPage;
					dwspPage+=1;
					param.rows = dwspRows;
					param.approvalStatus = "001",
					param.approverId = "${user.teacher.id}"
				}else if(id == 'wyspListTable') {
					param.page = wyspPage;
					wyspPage+=1;
					param.rows = wyspRows;
					param.approvalStatus = "000",
					param.approverId = "${user.teacher.id}"
				}else if(id == 'myListTable') {
					param.page = myPage;
					myPage+=1;
					param.rows = myRows;
					param.applyerId = "${user.teacher.id}";
				}else if(id == 'ccListTable') {
					param.page = ccPage;
					ccPage+=1;
					param.rows = ccRows;
					param.ccId = "${user.teacher.id}";
				}
				loadItem(param, id);
			})
			var param = {
				page: dwspPage,
				rows: dwspRows,
				approvalStatus: "001",
				approverId: "${user.teacher.id}"
			}
			dwspPage+=1;
			loadItem(param,"dwspListTable");
		});
		
		function loadItem(param, id) {
			$.ajax({
				url: basePath + '/ls/work/approval/page/query',
				type: 'post',
				dataType: 'json',
				data: param,
				success: function(data) {
					var html = "";
					if(data.data.rows.length == 0 || param.page*param.rows >= data.data.total) {// 如果没有数据
	            		 $("#" + id).closest(".weui_tab_bd_item").find('.loadData').removeClass("dropload-hasData").addClass("dropload-noData").html("没有更多数据了");
	                }
					for(var i in data.data.rows) {
						var itm = data.data.rows[i];
						html += '<a href="<%=basePath%>/ls/work/approval/detail/'+itm.id+'"><div class="weui_media_box weui_media_appmsg border-bottom1">\
		                    <div class="weui_media_hd">\
		                        <img class="weui_media_appmsg_thumb circle" src="${config.imgUrl}${user.teacher.headImgUrl}" alt="">\
		                    </div>\
		                    <div class="weui_media_bd">\
		                        <h4 class="weui_media_title"> <span class="f-gray f14 fr">'+getDateDiff((itm.approvalTime == null ? itm.applyTime : itm.approvalTime), "yyyy/MM/dd")+'</span>'+itm.approvalTypeText+'</h4>\
		                        <div class="weui_media_desc f-grayf9 mt10">';
		                    html += '<p class="'+(itm.approvalStatus == '000' ? 'f-green2':'f-yellow2')+'">'+itm.approvalStatusText+'</p>';
		                    html += '</div></div></div></a>';
					}
					$("#" + id).append(html);
				}
			});
		}
	</script>
</body>
</html>